*************************************************************************************************
***                                                                                           ***
***   Do file for: Hernandez-Huerta, Victor and Maria Inclan. 2025.                           ***
***   "Populist Attacks on Academic Freedom:                                                  ***
***   How Populist Leadership Erodes Academic Freedom in Liberal and Electoral Democracies."  ***
***   Perspectives on Politics.                                                               ***
***   Last update: May 23, 2025                                                               ***
***                                                                                           ***
*************************************************************************************************

**** using gpd_v2_20220427.xls
* This is the Global Populism Dataset
* This data set contains a new generated variable called "totalaverage"
* "totalaverage" is the average of all the values of "averagerubric" for each administration

generate COWcode = .
replace COWcode = 339 if country=="Albania" 
replace COWcode = 160 if country=="Argentina" 
replace COWcode = 371 if country=="Armenia" 
replace COWcode = 305 if country=="Austria" 
replace COWcode = 145 if country=="Bolivia" 
replace COWcode = 140 if country=="Brazil" 
replace COWcode = 355 if country=="Bulgaria" 
replace COWcode = 20 if country=="Canada" 
replace COWcode = 155 if country=="Chile" 
replace COWcode = 100 if country=="Colombia" 
replace COWcode = 94 if country=="Costa Rica" 
replace COWcode = 344 if country=="Croatia" 
replace COWcode = 316 if country=="Czechia" 
replace COWcode = 42 if country=="Dominican Republic" 
replace COWcode = 130 if country=="Ecuador" 
replace COWcode = 92 if country=="El Salvador" 
replace COWcode = 366 if country=="Estonia" 
replace COWcode = 375 if country=="Finland" 
replace COWcode = 220 if country=="France" 
replace COWcode = 372 if country=="Georgia" 
replace COWcode = 255 if country=="Germany" 
replace COWcode = 452 if country=="Ghana" 
replace COWcode = 350 if country=="Greece" 
replace COWcode = 90 if country=="Guatemala" 
replace COWcode = 91 if country=="Honduras" 
replace COWcode = 310 if country=="Hungary" 
replace COWcode = 750 if country=="India" 
replace COWcode = 205 if country=="Ireland" 
replace COWcode = 325 if country=="Italy" 
replace COWcode = 740 if country=="Japan" 
replace COWcode = 367 if country=="Latvia" 
replace COWcode = 368 if country=="Lithuania" 
replace COWcode = 343 if country=="North Macedonia" 
replace COWcode = 70 if country=="Mexico" 
replace COWcode = 359 if country=="Moldova" 
replace COWcode = 712 if country=="Mongolia" 
replace COWcode = 341 if country=="Montenegro" 
replace COWcode = 210 if country=="Netherlands" 
replace COWcode = 93 if country=="Nicaragua" 
replace COWcode = 385 if country=="Norway" 
replace COWcode = 95 if country=="Panama" 
replace COWcode = 150 if country=="Paraguay" 
replace COWcode = 135 if country=="Peru" 
replace COWcode = 290 if country=="Poland" 
replace COWcode = 360 if country=="Romania" 
replace COWcode = 345 if country=="Serbia" 
replace COWcode = 317 if country=="Slovakia" 
replace COWcode = 349 if country=="Slovenia" 
replace COWcode = 230 if country=="Spain" 
replace COWcode = 380 if country=="Sweden" 
replace COWcode = 640 if country=="Turkey" 
replace COWcode = 200 if country=="UK" 
replace COWcode = 2 if country=="United States" 
replace COWcode = 165 if country=="Uruguay" 
replace COWcode = 850 if country=="Indonesia" 
replace COWcode = 840 if country=="Philippines" 
replace COWcode = 713 if country=="Taiwan" 
replace COWcode = 560 if country=="South Africa" 
replace COWcode = 900 if country=="Australia" 

*Dropping missing values
drop if COWcode == .
drop if year ==.

save populism, replace
clear
*This ("populism.dta") is the clean Global Populism Dataset (after re-coding country labels and dropping missing data)

**** Merging V-Dem data with The Global Populism Database v2
**** Using /Users/hernanv/Desktop/Academic fredom data/V-Dem-CY-FullOthers_STATA_v13/V-Dem-CY-Full+Others-v13.dta
merge m:1 COWcode year using populism
keep if _merge == 3
drop _merge
save vdemconpopulismo
*This ("vdemconpopulismo.dta") is the data set that merges V-dem and the clean Global Populism Dataset
* All the following analyses use this merged dataset


*********************
*** Main analysis ***
*********************

*** Using vdemconpopulismo.dta


*** Prepare for panel data
xtset COWcode year 

*** Variable transformations and scope conditions
* Consider only democratic country years (dropping 0: Closed autocracy and 1: Electoral autocracy)
drop if v2x_regime == 0
drop if v2x_regime == 1
* Log (population)
generate log_pop = log(e_wb_pop)
* Lag1.  L1.totalaverage
* Generating a lag for previous two years averaged
gen totalaverage_previous2 = (L1.totalaverage + L2.totalaverage) / 2


*** Table 1, paper
**** Model 1: Populism
xtreg v2xca_academ totalaverage if year>1999, fe 
**** Model 2: Full model minus liberal dem
xtreg v2xca_academ totalaverage v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop e_gdppc e_miinflat if year>1999, fe
**** Model 3: Full model, liberal democracy included
xtreg v2xca_academ totalaverage v2x_libdem v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop e_gdppc e_miinflat if year>1999, fe
**** Model 4: Model 3 minus economic controls 
xtreg v2xca_academ totalaverage v2x_libdem v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop if year>1999, fe
*esttab using acafree_R2Table_1.csv, se star(* 0.10 ** 0.05 *** 0.01 )

*Multicolinearity test using model 3
reg v2xca_academ totalaverage v2x_libdem v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop e_gdppc e_miinflat if year>1999
vif

**************************
*** Robusteness checks ***
**************************

**** Table A2. Alternative specification of the dependent variable: Freedom to research and teach (v2cafres)
***** Model 1: Populism
xtreg v2cafres totalaverage if year>1999, fe 
**** Model 2: Full model - liberal dem
xtreg v2cafres totalaverage v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop e_gdppc e_miinflat if year>1999, fe
**** Model 3: Full model liberal democracy included
xtreg v2cafres totalaverage v2x_libdem v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop e_gdppc e_miinflat if year>1999, fe
**** Model 4: Model 3 minus economic controls
xtreg v2cafres totalaverage v2x_libdem v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop if year>1999, fe
*esttab using acafree_R2Table_v2cafres.csv, se star(* 0.10 ** 0.05 *** 0.01 ) 


**** Table A3. Alternative specification of the dependent variable: Freedom of academic exchange and dissemination (v2cafexch)
***** Model 1: Populism
xtreg v2cafexch totalaverage if year>1999, fe 
**** Model 2: Full model - liberal dem
xtreg v2cafexch totalaverage v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop e_gdppc e_miinflat if year>1999, fe
**** Model 3: Full model liberal democracy included
xtreg v2cafexch totalaverage v2x_libdem v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop e_gdppc e_miinflat if year>1999, fe
**** Model 4: Model 3 minus economic controls
xtreg v2cafexch totalaverage v2x_libdem v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop if year>1999, fe
*esttab using acafree_R2Table_alternativeDP.csv, se star(* 0.10 ** 0.05 *** 0.01 )


****Table A5. Replication of Table 1 adding cases pre-2000
**** Model 1: Populism
xtreg v2xca_academ totalaverage, fe 
**** Model 2: Full model minus liberal dem
xtreg v2xca_academ totalaverage v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop e_gdppc e_miinflat, fe
**** Model 3: Full model, liberal democracy included
xtreg v2xca_academ totalaverage v2x_libdem v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop e_gdppc e_miinflat, fe
**** Model 4 No economic indicators
xtreg v2xca_academ totalaverage v2x_libdem v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop, fe
*esttab using acafree_R2Table_A5.csv, se star(* 0.10 ** 0.05 *** 0.01 )
 

*** Table A6
*** Dependent variable: v2xca_academ
*** Alternatove ibdependent variable (totalaverage with one lag) 
**** Model 1: Populism
xtreg v2xca_academ L1.totalaverage if year>1999, fe 
**** Model 2: Full model - liberal dem
xtreg v2xca_academ L1.totalaverage v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop e_gdppc e_miinflat if year>1999, fe
**** Model 3: Full model liberal democracy (v2x_libdem) included
xtreg v2xca_academ L1.totalaverage v2x_libdem v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop e_gdppc e_miinflat if year>1999, fe
**** Model 4: Model 3 minus economic controls
xtreg v2xca_academ L1.totalaverage v2x_libdem v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop if year>1999, fe
*esttab using acafree_R2Table_ALag1.csv, se star(* 0.10 ** 0.05 *** 0.01 )

*** Table A7
*** DP1 totalaverage
*** Alternative IV: populism value over the two prior years, excluding the current year (average of t−1 and t−2)
**** Model 1: Populism
xtreg v2xca_academ totalaverage_previous2 if year>1999, fe 
**** Model 2: Full model - liberal dem
xtreg v2xca_academ totalaverage_previous2 v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop e_gdppc e_miinflat if year>1999, fe
**** Model 3: Full model liberal democracy (v2x_libdem) included
xtreg v2xca_academ totalaverage_previous2 v2x_libdem v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop e_gdppc e_miinflat if year>1999, fe
**** Model 4: Model 3 minus economic controls
xtreg v2xca_academ totalaverage_previous2 v2x_libdem v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop if year>1999, fe
*esttab using acafree_R2Table_ALag2.csv, se star(* 0.10 ** 0.05 *** 0.01 )

exit, clear


*** Table A4. Replication of the models in Table 1 using an alternative measure of regime type for case selection (the Boix et al. regime measure e_boix_regime
* NOTE: Open again vdemconpopulismo.dta
* Then drop cases using e_boix_regime
drop if e_boix_regime == 0
* Then, replicate Table 1
**** Model 1: Populism
xtreg v2xca_academ totalaverage if year>1999, fe 
**** Model 2: Full model minus liberal dem
xtreg v2xca_academ totalaverage v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop e_gdppc e_miinflat if year>1999, fe
**** Model 3: Full model, liberal democracy included
xtreg v2xca_academ totalaverage v2x_libdem v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop e_gdppc e_miinflat if year>1999, fe
**** Model 4: Model 3 minus economic controls 
xtreg v2xca_academ totalaverage v2x_libdem v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop if year>1999, fe
*esttab using acafree_R2Table_1.csv, se star(* 0.10 ** 0.05 *** 0.01 )
 
 
**************** 
***  GRAPHS  ***
**************** 

*** Using vdemconpopulismo.dta

**** Figure 1. Visualization of the academic freedom index for democratic country-years in which the populism index is available
* First install panelview
* ssc install panelview, all
panelview  v2xca_academ, i(country_text_id) t(year) type(treat) legend(off)

**** Figure 2. Predicted probabilities of the level of academic freedom across changes in populist discourse,/
* with a histogram showing the distribution of populism scores across their full range. 
* First intall grinset
* ssc install grinset, replace
* Run model for the estimation
xtreg v2xca_academ totalaverage v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop e_gdppc e_miinflat, fe
margins, at(totalaverage=(0.2(0.2)1.8))
* First generate main graph
marginsplot
* Then, add a historgram
grinset r=5: histogram totalaverage
* Finally move the inset to a different position, change size, and change scaling of text and markers
grinset t=50 r=90, size(35) scale(0.6)

**** Figure 3. Predicted probabilities of the level of academic freedom across changes in the liberal democracy index
xtreg v2xca_academ totalaverage v2x_libdem v2x_jucon v2xlg_legcon v2caprotac v2smpolsoc log_pop e_gdppc e_miinflat if year>1999, fe
margins, at(v2x_libdem=(0.25(0.05)0.9))
marginsplot

*** Figure in Appendix
**** Figure A1: Visualization of the populist discourse of political leaders among electoral and liberal democracies.
***Populism index
panelview v2xca_academ totalaverage, i(country_text_id) t(year) type(treat) legend(off)


